package com.hnevc.androidui11;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * Created by Administrator on 2018/6/29.
 */

public class MybaseAdapter extends BaseAdapter{
    int[] datas = new int[]{12,34,45,6,7,8};
    //声明一个山下问对象
    Context mContext;
    //写一个传递上下文对象的构造方式
    public  MybaseAdapter(Context context){
        mContext = context;
    }
    @Override
    public int getCount() {
        return datas.length;
    }

    @Override
    public Object getItem(int position) {
        return datas[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView textView = new TextView(mContext);
        textView.setText(datas[position]+"数据项");
        return textView;
    }
}
